<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * Hilo
<span class='line'>  3</span>  * Copyright 2015 alibaba.com
<span class='line'>  4</span>  * Licensed under the MIT License
<span class='line'>  5</span>  */</span><span class="WHIT">
<span class='line'>  6</span> 
<span class='line'>  7</span> </span><span class="COMM">/**
<span class='line'>  8</span>  * @class 工具方法集合
<span class='line'>  9</span>  * @static
<span class='line'> 10</span>  * @module hilo/util/util
<span class='line'> 11</span>  */</span><span class="WHIT">
<span class='line'> 12</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">util</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 13</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 14</span>      * 简单的浅复制对象。
<span class='line'> 15</span>      * @param {Object} target 要复制的目标对象。
<span class='line'> 16</span>      * @param {Object} source 要复制的源对象。
<span class='line'> 17</span>      * @param {Boolean} strict 指示是否复制未定义的属性，默认为false，即不复制未定义的属性。
<span class='line'> 18</span>      * @returns {Object} 复制后的对象。
<span class='line'> 19</span>      */</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="WHIT">    </span><span class="NAME">copy</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">source</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">strict</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 21</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">source</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 22</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">strict</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">target.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 23</span> </span><span class="WHIT">                </span><span class="NAME">target</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">source</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 24</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 26</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 28</span> </span><span class="PUNC">}</span><span class="PUNC">;</span></pre></body></html>